Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simulated hardware #69

Merged
merged 9 commits into from
Jul 30, 2024
Merged

Conversation

thomaswmorris
Copy link
Collaborator

Inspired by conversations with some beamline scientists, it would help to have more concrete optimization problems. This adds a lightweight simulation of a beamline mimicking a KB mirror endstation. We may add more examples in the future.

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Member

@mrakitin mrakitin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, but needs some cleanup (details below).

Comment on lines 69 to 70
dets: Sequence[Signal] = [],
detectors: Sequence[Signal] = [],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use immutable defaults, e.g., None and assign a list later in the __init__ method.

Comment on lines 845 to 841
x = self.dofs(active=True).transform(x)
# x = self.dofs(active=True).transform(x)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove it and have a docsting explaining x does not need to be normalized.

Comment on lines 114 to 115
for item in items:
yield item
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on linter recommendation for https://github.com/NSLS-II-HEX/hextools/blob/870b1c928746501ca2f8f4404c49d895986c4e2f/src/hextools/germ/ophyd.py#L124:

Suggested change
for item in items:
yield item
yield from items

Comment on lines +6 to +15
class HDF5Handler(HandlerBase):
specs = {"HDF5"}

def __init__(self, filename):
self._name = filename

def __call__(self, frame):
with h5py.File(self._name, "r") as f:
entry = f["/entry/image"]
return entry[frame]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's create an issue to make it compatible with databroker v2.

from . import functions # noqa


def get_beam_stats(image, threshold=0.5):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function has a duplicate in src/blop/digestion/__init__.py. Let's leave just one of them.

@thomaswmorris thomaswmorris merged commit c1257a7 into NSLS-II:main Jul 30, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants